public class test {
    public static void main(String[] args) {
        Object n1=new Object();
        Object n2=new Object();
        Thread t1=new Thread(()->{
            System.out.println("A");
            synchronized (n1){
                n1.notify();
            }
        });
        Thread t2=new Thread(()->{
            synchronized (n1){
                try{
                    n1.wait();
                }catch (InterruptedException e){
                    e.printStackTrace();
                }
            }
            System.out.println("B");
            synchronized (n2){
                n2.notify();
            }
        });
        Thread t3=new Thread(()->{
            synchronized (n2){
                try{
                    n2.wait();
                }catch (InterruptedException e){
                    e.printStackTrace();
                }
            }
            System.out.println("C");
        });

        t2.start();
        t3.start();
        try {
            Thread.sleep(100);
        }catch (InterruptedException e){
            e.printStackTrace();
        }
        t1.start();
    }
}
